﻿using System.Web.Mvc;
using System.Web.Routing;
using CodeCamp.Controllers;

namespace CodeCampWeb
{
  public class MvcApplication : System.Web.HttpApplication
  {
    private const string defaultEventName = "2012";

    public static void RegisterRoutes( RouteCollection routes )
    {
      routes.IgnoreRoute( "{resource}.axd/{*pathInfo}" );
      routes.IgnoreRoute( "favicon.ico" );

      routes.MapRoute(
        "RouteWithDefaultIndex",                    // route name
        "{eventName}/{controller}/{action}/{id}",   // URL pattern with parameters
        new                                         // parameter defaults
        {
          eventName = defaultEventName,
          controller = "Home",
          action = "Index",
          id = string.Empty
        },
        new                                         // constraints
        {
          controller = "Home|JointEvent"
        }  );

      routes.MapRoute(
        "RouteWithDefaultList",                     // route name
        "{eventName}/{controller}/{action}/{id}",   // URL pattern with parameters
        new                                         // parameter defaults
        {
          eventName = defaultEventName,
          action = "List",
          id = string.Empty
        } );
    }

    protected void Application_Start()
    {
      RegisterRoutes( RouteTable.Routes );
    }
  }
}